<template>
	<view>
		<view class="head-bgc"></view>
		<view class="cont-box">
			<view class="cont-box-bg">
				<view class="h-tit-box">
					<view class="c-box-tit">学生证</view>
					<image class="head-img" src="../../static/logo.png" mode=""></image>
				</view>
				<view class="name-box">
					<view class="n-tit">姓名</view>
					<input v-model="list.stu_name" focus="true" placeholder="请填写姓名" class="n-name" placeholder-style="color: #C2C7CC;"  />
					<!-- <view class="n-name">{{ list.stu_name }}</view> -->
					<image src="/static/right.png" style="width: 45upx;height: 45upx;"></image>
				</view>
				<view class="bot-line"></view>
				<view class="name-box">
					<view class="n-tit">学历</view>
					<input v-model="list.edu_type_name" placeholder="请填写学历" class="n-name" placeholder-style="color: #C2C7CC;"  />
					<!-- <view class="n-name">{{ list.edu_type_name }}</view> -->
					<image src="/static/right.png" style="width: 45upx;height: 45upx;"></image>
				</view>
				<view class="bot-line"></view>
				<view class="name-box">
					<view class="n-tit">学校</view>
					<input v-model="list.school_id_name" placeholder="请填写学校" class="n-name" placeholder-style="color: #C2C7CC;"  />
					<!-- <view class="n-name">{{ list.school_id_name }}</view> -->
					<image src="/static/right.png" style="width: 45upx;height: 45upx;"></image>
				</view>
				<view class="bot-line"></view>
				<view class="name-box">
					<view class="n-tit">院系</view>
					<input v-model="list.department_name" placeholder="请填写院系" class="n-name" placeholder-style="color: #C2C7CC;"  />
					<!-- <view class="n-name">{{ list.department_name }}</view> -->
					<image src="/static/right.png" style="width: 45upx;height: 45upx;"></image>
				</view>
				<view class="bot-line"></view>
				<view class="name-box">
					<view class="n-tit">专业</view>
					<input v-model="list.major" placeholder="请填写专业" class="n-name" placeholder-style="color: #C2C7CC;"  />
					<!-- <view class="n-name">{{ list.major }}</view> -->
					<image src="/static/right.png" style="width: 45upx;height: 45upx;"></image>
				</view>
				<view class="bot-line"></view>
				<view class="name-box" @click="showTime=true">
					<view class="n-tit">入学时间</view>
					<input v-model="enterTimer" placeholder="请填写入学时间" class="n-name" placeholder-style="color: #C2C7CC;"  />
					<!-- <view class="n-name">{{ enterTimer }}</view> -->
					<image src="/static/right.png" style="width: 45upx;height: 45upx;"></image>
				</view>
				<view class="bot-line"></view>
				<view class="name-box">
					<view class="n-tit">人生座右铭</view>
					<view class="n-name">人生座右铭</view>
					<image src="/static/right.png" style="width: 45upx;height: 45upx;"></image>
				</view>
				<view class="bot-line"></view>
				<navigator url="./write_student_card" style="text-align: center;">
					<image class="bot-img" src="../../static/logo.png"></image>
				</navigator>
			</view>
		</view>
		<button class="back-sch" v-if="btn==false" @click="backSchool()">回到母校</button>
		<button class="save-btn" v-if="btn" @click="saveCard()">保存修改</button>
		<u-calendar v-model="showTime" :mode="'date'" @change="change" max-date="2100-01-01"></u-calendar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:{
					major:'',
					stu_name:'',
					edu_type:'',
					school_id:'',
					school_name:'',
					edu_type_name:'',
					department_name:'',
					enter_school_time:'',
				},
				btn:false,
				showTime:false,
				enterTimer:'',	//入学时间
				// list:{
				// 	major:'',
				// 	stu_name:'',
				// 	edu_type:'',
				// 	school_id:'',
				// 	school_name:'',
				// 	edu_type_name:'',
				// 	department_name:'',
				// 	enter_school_time:'',
				// },
			}
		},
		onLoad(e) {
			this.list.school_id = e.school_id
			this.getStudentInfo()
			if(e.school_id){
				this.btn=true
			}
		},
		methods: {
			async getStudentInfo(){
				const res = await this.get('/index/User/get_student_info')
				this.list = res.data
				let time = res.data.enter_school_time
				this.enterTimer = time.substring(0,10)
			},
			async saveCard(){
				const res = await this.post('/Index/User/save_school_student',this.list)
				if(res.code==200){
					uni.showToast({
						title:'修改成功',
						duration:800,
						success:() => {
							setTimeout(() => {
							    uni.navigateTo({
							    	url:'./alumni_circle?school_id='+this.list.school_id
							    })
							},800)
						}
					})
				}else{
					uni.showToast({
						title:'修改失败'
					})
				}
			},
			change(e) {
				let time = e.result
				this.enterTimer = time.substring(0,10)
				this.list.enter_school_time = this.enterTimer
			},
			backSchool(){
				uni.navigateTo({
					url:'./alumni_circle?school_id='+this.list.school_id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.head-bgc{
		width: 100%;
		height: 384upx;
		background: #3291F8;
		border-radius: 0 0 80upx 80upx;
	}
	.cont-box{
		width: 100%;
		.cont-box-bg{
			width: 670upx;
			background: #FFFFFF;
			border-radius: 50upx;
			margin-bottom: 200upx;
			border: 6upx solid rgba(237, 234, 244, 100);
			position: absolute;
			top: 108upx;
			left: 40upx;
		}
		.h-tit-box{
			text-align: center;
			.c-box-tit{
				color: #101010;
				font-size: 56upx;
				margin-top: 40upx;
				letter-spacing: 10upx;
			}
			.head-img{
				width: 186upx;
				height: 186upx;
				border-radius: 50%;
				margin: 30upx 0 72upx 0;
			}
		}
		.name-box{
			display: flex;
			padding: 0 50upx;
			align-items: center;
			.n-tit{
				width: 180upx;
				color: #C2C7CC;
				font-size: 28upx;
			}
			.n-name{
				width: 370upx;
				color: #030303;
				font-size: 32upx;
			}
		}
		.bot-line{
			height: 2upx;
			width: 568upx;
			background: #EDEAF4;
			margin: 32upx 50upx;
		}
		.bot-img{
			width: 186upx;
			height: 186upx;
			margin: 70upx 0;
		}
	}
	.back-sch{
		width: 670upx;
		height: 88upx;
		color: #FFFFFF;
		font-size: 34upx;
		line-height: 88upx;
		background: #3291F8;
		position: fixed;
		bottom: 50upx;
		left: 40upx;
	}
	.save-btn{
		width: 670upx;
		height: 88upx;
		color: #FFFFFF;
		font-size: 34upx;
		line-height: 88upx;
		background: #3291F8;
		border-radius: 15upx;
		position: fixed;
		bottom: 50upx;
		left: 40upx;
	}
</style>
